using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class RankUI : MonoBehaviour
{
    [SerializeField] private Transform rankContainer;

    private void OnEnable() {
        ShowRankInfo();
    }

    private void OnDisable() {
        
    }

    private void ShowRankInfo()
    {
        PlayerScoreData data = ScoreManager.Instance.LoadPlayerScoreData();

        for(int i=0; i<rankContainer.childCount; i++)
        {
            var child = rankContainer.GetChild(i);

            child.Find("Id").GetComponent<Text>().text = (i+1).ToString();
            child.Find("Name").GetComponent<Text>().text = data.list[i].name;
            child.Find("Score").GetComponent<Text>().text = data.list[i].score.ToString();
        }
    }
}
